package com.sw.small_world.adapter.topicsquare;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sw.small_world.R;
import com.sw.small_world.utils.ConstantUtils;
import com.sw.small_world.utils.StartUtils;
import com.sw.small_world.widgets.CircleImageView;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/3/21.
 */

public class TopicSquareDetailAdapter extends BaseAdapter implements View.OnClickListener{
    ArrayList<String> list = new ArrayList<>();
    private Context context;

    public TopicSquareDetailAdapter(ArrayList<String> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.item_topic_square_detail, new FrameLayout(context));
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.topicSquarePortrait.setOnClickListener(this);
        holder.topicSquareName.setOnClickListener(this);
        return convertView;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.topic_square_portrait:
            case R.id.topic_square_name:
                StartUtils.startActivityById(context, ConstantUtils.PERSON_INFO);
                break;
        }
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    static class ViewHolder {
        @Bind(R.id.topic_square_portrait)
        CircleImageView topicSquarePortrait;
        @Bind(R.id.topic_square_name)
        TextView topicSquareName;
        @Bind(R.id.topic_square_deep)
        TextView topicSquareDeep;
        @Bind(R.id.topic_comment_content)
        TextView topicCommentContent;
        @Bind(R.id.topic_square_time)
        TextView topicSquareTime;
        @Bind(R.id.tv_author)
        TextView tvAuthor;
        @Bind(R.id.author_replay)
        TextView authorReplay;
        @Bind(R.id.ll3)
        LinearLayout ll3;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
